package com.work.washer.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.work.washer.mapper.UserMapper;
import com.work.washer.model.User;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author
 * @description 针对表【user】的数据库操作Service实现
 * @createDate 2024-02-20 10:07:14
 */
@Service
public class UserService extends ServiceImpl<UserMapper, User>
        implements IService<User> {

    public User login(User user) {
        User userDo = lambdaQuery().eq(User::getPhone, user.getPhone()).one();
        if (userDo == null) {
            user.setCreateDate(new Date());
            user.setId(null);
            user.setType(user.getType());
            user.setName("用户"+user.getPhone());
            this.save(user);
            return user;
        }
        return userDo;
    }
}




